package com.asia.action.ods;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.asia.domain.ods.OdsFieldTable;
import com.util.HibernateUtil;
import org.apache.struts2.ServletActionContext;
import org.hibernate.Session;
import org.hibernate.Transaction;
import com.asia.service.ods.ODSService;

import com.opensymphony.xwork2.ActionSupport;

public class DataLoad extends ActionSupport
{
    private static HttpServletResponse response=null;
    private static HttpServletRequest request=null;
    private ODSService odsService;

    public ODSService getOdsService() {
        return odsService;
    }

    public void setOdsService(ODSService odsService) {
        this.odsService = odsService;
    }

    public String Single_data_add()
    {
        response=ServletActionContext.getResponse();
        request=ServletActionContext.getRequest();

        OdsFieldTable odsFieldTable = new OdsFieldTable();

//		odsFieldTable.setFieldId(100);
        odsFieldTable.setOdsTableName(request.getParameter("ods_table_name"));
        odsFieldTable.setOdsFieldColumnNumber(request.getParameter("ods_field_column_number"));
        odsFieldTable.setOdsFieldDatatype(request.getParameter("ods_field_datatype"));
        odsFieldTable.setOdsFieldDimen(request.getParameter("ods_field_dimen"));
        odsFieldTable.setOdsFieldMainFileColumnNumber(request.getParameter("ods_field_main_file_column_number"));
        odsFieldTable.setOdsFieldMoreinfo(request.getParameter("ods_field_moreinfo"));
        odsFieldTable.setOdsFieldName(request.getParameter("ods_field_name"));
        odsFieldTable.setOdsFieldSpecification(request.getParameter("ods_field_specification"));
        odsFieldTable.setOdsInterfaceId(request.getParameter("ods_interface_id"));
        try {
            odsService.insert(odsFieldTable);
        } catch (Exception e) {
            // TODO: handle exception
            System.out.println("err1");
            return null;
        }
        return SUCCESS;
    }
}
